package logic

import (
	"context"
	"youngwind-first/rpcdemo/internal/svc"
	"youngwind-first/rpcdemo/model/gorm_model"
	"youngwind-first/rpcdemo/rpcdemo"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteUserLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic {
	return &DeleteUserLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteUserLogic) DeleteUser(in *rpcdemo.User) (*rpcdemo.Success, error) {

	ub := &gorm_model.User{}
	ub.Id = in.Id

	err := l.svcCtx.DbEngin.Delete(&ub).Error
	if err != nil {
		return nil, err
	}
	return &rpcdemo.Success{}, nil
}
